package com.example.shiro;

import org.apache.shiro.SecurityUtils;
import org.apache.shiro.authc.UsernamePasswordToken;
import org.apache.shiro.config.IniSecurityManagerFactory;
import org.apache.shiro.mgt.SecurityManager;
import org.apache.shiro.subject.Subject;
import org.apache.shiro.util.Factory;
import org.junit.Test;


/**
 * @description:
 * @author: guoc
 * @createDate: 2020/4/30 13:48
 */
public class authenticatorTest2 {

    @Test
    public void testauthenticator(){
        Factory<SecurityManager> factory= new IniSecurityManagerFactory("classpath:shiro.ini");
        SecurityManager instance = factory.getInstance();
        Subject subject = SecurityUtils.getSubject();
        SecurityUtils.setSecurityManager(instance);

        UsernamePasswordToken usernamePasswordToken=new UsernamePasswordToken("abner","123");
        subject.login(usernamePasswordToken);
    }



}
